package hu.plajko.client;

import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VLayout;

public class ClickThroughLayout extends VLayout {

	private HLayout inner = new HLayout();
	private Canvas dummy=new Canvas();

	public static enum LayoutPosition {
		TL, T, TR, R, BL, B, BR, L, C
	};

	public ClickThroughLayout(LayoutPosition position, Canvas c) {
		
		
		dummy.setHeight(1);
		dummy.setWidth(1);
		
		setWidth100();
		setHeight100();
		
		inner.setAutoHeight();
		inner.setWidth100();

		switch (position) {
		case TL:
			inner.setAlign(Alignment.LEFT);
			setAlign(VerticalAlignment.TOP);
			break;
		case T:
			inner.setAlign(Alignment.CENTER);
			setAlign(VerticalAlignment.TOP);
			break;
		case TR:
			inner.setAlign(Alignment.RIGHT);
			setAlign(VerticalAlignment.TOP);
			break;
		case R:
			inner.setAlign(Alignment.RIGHT);
			setAlign(VerticalAlignment.CENTER);
			break;
		case BL:
			inner.setAlign(Alignment.LEFT);
			setAlign(VerticalAlignment.BOTTOM);
			break;
		case B:
			inner.setAlign(Alignment.CENTER);
			setAlign(VerticalAlignment.BOTTOM);
			break;
		case BR:
			inner.setAlign(Alignment.RIGHT);
			setAlign(VerticalAlignment.BOTTOM);
			break;
		case L:
			inner.setAlign(Alignment.LEFT);
			setAlign(VerticalAlignment.CENTER);
			break;
		case C:
		default:
			inner.setAlign(Alignment.CENTER);
			setAlign(VerticalAlignment.CENTER);
			break;
		}

		inner.addMember(c);
		addMember(inner);
	}
}
